<template>
  <div class="sql-keywords">
    <el-dialog
      v-model="dialogVisible"
      title="SQL关键字"
      width="800px"
      :close-on-click-modal="false"
    >
      <div class="keywords-container">
        <div class="keywords-header">
          <el-input
            v-model="searchText"
            placeholder="搜索关键字"
            clearable
            style="width: 200px"
          />
        </div>
        <div class="keywords-content">
          <el-tabs v-model="activeCategory">
            <el-tab-pane 
              v-for="category in categories" 
              :key="category.name" 
              :label="category.label" 
              :name="category.name"
            >
              <div class="keywords-grid">
                <el-button
                  v-for="keyword in filteredKeywords(category.keywords)"
                  :key="keyword.name"
                  type="primary"
                  link
                  @click="useKeyword(keyword)"
                >
                  {{ keyword.name }}
                  <span>{{ keyword.description }}</span>
                </el-button>
              </div>
            </el-tab-pane>
          </el-tabs>
        </div>
      </div>
    </el-dialog>
  </div>
</template>

<script setup>
import { ref, computed } from 'vue'

const dialogVisible = ref(false)
const searchText = ref('')
const activeCategory = ref('common')

const categories = [
  {
    name: 'basic',
    label: '基础语法',
    keywords: [
      { name: 'SELECT', description: '选择数据' },
      { name: 'FROM', description: '指定表' },
      { name: 'WHERE', description: '条件筛选' },
      { name: 'GROUP BY', description: '分组' },
      { name: 'ORDER BY', description: '排序' },
      { name: 'HAVING', description: '分组后筛选' },
      { name: 'LIMIT', description: '限制结果' },
      { name: 'OFFSET', description: '偏移量' },
      { name: 'DISTINCT', description: '去重' },
      { name: 'AS', description: '别名' },
      { name: 'WITH', description: '公共表表达式' },
      { name: 'UNION', description: '合并结果集' },
      { name: 'UNION ALL', description: '合并所有结果集' },
      { name: 'INTERSECT', description: '交集' },
      { name: 'EXCEPT', description: '差集' }
    ]
  },
  {
    name: 'joins',
    label: '表连接',
    keywords: [
      { name: 'JOIN', description: '连接表' },
      { name: 'INNER JOIN', description: '内连接' },
      { name: 'LEFT JOIN', description: '左连接' },
      { name: 'RIGHT JOIN', description: '右连接' },
      { name: 'FULL JOIN', description: '全连接' },
      { name: 'CROSS JOIN', description: '交叉连接' },
      { name: 'NATURAL JOIN', description: '自然连接' },
      { name: 'ON', description: '连接条件' },
      { name: 'USING', description: '使用列连接' }
    ]
  },
  {
    name: 'operators',
    label: '运算符',
    keywords: [
      { name: '=', description: '等于' },
      { name: '!=', description: '不等于' },
      { name: '<>', description: '不等于' },
      { name: '>', description: '大于' },
      { name: '<', description: '小于' },
      { name: '>=', description: '大于等于' },
      { name: '<=', description: '小于等于' },
      { name: 'IN', description: '在集合中' },
      { name: 'NOT IN', description: '不在集合中' },
      { name: 'LIKE', description: '模糊匹配' },
      { name: 'NOT LIKE', description: '不匹配' },
      { name: 'IS NULL', description: '为空' },
      { name: 'IS NOT NULL', description: '不为空' },
      { name: 'BETWEEN', description: '在范围内' },
      { name: 'NOT BETWEEN', description: '不在范围内' },
      { name: 'EXISTS', description: '存在' },
      { name: 'NOT EXISTS', description: '不存在' },
      { name: 'AND', description: '逻辑与' },
      { name: 'OR', description: '逻辑或' },
      { name: 'NOT', description: '逻辑非' },
      { name: 'XOR', description: '逻辑异或' },
      { name: 'ALL', description: '所有' },
      { name: 'ANY', description: '任意' },
      { name: 'SOME', description: '某些' }
    ]
  },
  {
    name: 'functions',
    label: '常用函数',
    keywords: [
      { name: 'COUNT()', description: '计数' },
      { name: 'SUM()', description: '求和' },
      { name: 'AVG()', description: '平均值' },
      { name: 'MAX()', description: '最大值' },
      { name: 'MIN()', description: '最小值' },
      { name: 'CONCAT()', description: '字符串连接' },
      { name: 'SUBSTRING()', description: '截取字符串' },
      { name: 'TRIM()', description: '去除空格' },
      { name: 'LENGTH()', description: '字符串长度' },
      { name: 'UPPER()', description: '转大写' },
      { name: 'LOWER()', description: '转小写' },
      { name: 'REPLACE()', description: '替换字符串' },
      { name: 'ROUND()', description: '四舍五入' },
      { name: 'CEIL()', description: '向上取整' },
      { name: 'FLOOR()', description: '向下取整' },
      { name: 'ABS()', description: '绝对值' },
      { name: 'MOD()', description: '取模' },
      { name: 'POW()', description: '幂运算' },
      { name: 'SQRT()', description: '平方根' },
      { name: 'NOW()', description: '当前时间' },
      { name: 'CURDATE()', description: '当前日期' },
      { name: 'CURTIME()', description: '当前时间' },
      { name: 'DATE_FORMAT()', description: '日期格式化' },
      { name: 'IF()', description: '条件判断' },
      { name: 'CASE WHEN', description: '条件分支' },
      { name: 'COALESCE()', description: '返回第一个非空值' },
      { name: 'NULLIF()', description: '相等返回NULL' },
      { name: 'CAST()', description: '类型转换' },
      { name: 'CONVERT()', description: '类型转换' }
    ]
  },
  {
    name: 'ddl',
    label: '数据定义',
    keywords: [
      { name: 'CREATE', description: '创建' },
      { name: 'ALTER', description: '修改' },
      { name: 'DROP', description: '删除' },
      { name: 'TRUNCATE', description: '清空' },
      { name: 'RENAME', description: '重命名' },
      { name: 'TABLE', description: '表' },
      { name: 'VIEW', description: '视图' },
      { name: 'INDEX', description: '索引' },
      { name: 'DATABASE', description: '数据库' },
      { name: 'SCHEMA', description: '模式' },
      { name: 'PRIMARY KEY', description: '主键' },
      { name: 'FOREIGN KEY', description: '外键' },
      { name: 'UNIQUE', description: '唯一' },
      { name: 'CHECK', description: '检查' },
      { name: 'DEFAULT', description: '默认值' },
      { name: 'AUTO_INCREMENT', description: '自增' },
      { name: 'COMMENT', description: '注释' }
    ]
  },
  {
    name: 'dml',
    label: '数据操作',
    keywords: [
      { name: 'INSERT', description: '插入' },
      { name: 'UPDATE', description: '更新' },
      { name: 'DELETE', description: '删除' },
      { name: 'MERGE', description: '合并' },
      { name: 'REPLACE', description: '替换' },
      { name: 'VALUES', description: '值' },
      { name: 'SET', description: '设置' },
      { name: 'INTO', description: '插入到' }
    ]
  },
  {
    name: 'tcl',
    label: '事务控制',
    keywords: [
      { name: 'COMMIT', description: '提交' },
      { name: 'ROLLBACK', description: '回滚' },
      { name: 'SAVEPOINT', description: '保存点' },
      { name: 'START TRANSACTION', description: '开始事务' },
      { name: 'SET TRANSACTION', description: '设置事务' }
    ]
  },
  {
    name: 'dcl',
    label: '数据控制',
    keywords: [
      { name: 'GRANT', description: '授权' },
      { name: 'REVOKE', description: '撤销授权' },
      { name: 'DENY', description: '拒绝' }
    ]
  },
  {
    name: 'mysql_functions',
    label: 'MySQL函数',
    keywords: [
      { name: 'JSON_ARRAYAGG()', description: '将值聚合为JSON数组' },
      { name: 'JSON_OBJECTAGG()', description: '将键值对聚合为JSON对象' },
      { name: 'JSON_MERGE()', description: '合并JSON文档' },
      { name: 'JSON_MERGE_PATCH()', description: '合并JSON文档(补丁)' },
      { name: 'JSON_MERGE_PRESERVE()', description: '合并JSON文档(保留)' },
      { name: 'JSON_PRETTY()', description: '格式化JSON' },
      { name: 'JSON_SEARCH()', description: '搜索JSON值' },
      { name: 'JSON_VALID()', description: '验证JSON' },
      { name: 'JSON_CONTAINS()', description: '检查JSON是否包含值' },
      { name: 'JSON_CONTAINS_PATH()', description: '检查JSON是否包含路径' },
      { name: 'JSON_KEYS()', description: '获取JSON键' },
      { name: 'JSON_LENGTH()', description: '获取JSON长度' },
      { name: 'JSON_REMOVE()', description: '移除JSON值' },
      { name: 'JSON_REPLACE()', description: '替换JSON值' },
      { name: 'JSON_SET()', description: '设置JSON值' },
      { name: 'JSON_UNQUOTE()', description: '移除JSON引号' },
      { name: 'JSON_QUOTE()', description: '添加JSON引号' },
      { name: 'JSON_DEPTH()', description: '获取JSON深度' },
      { name: 'JSON_TYPE()', description: '获取JSON类型' },
      { name: 'GROUP_CONCAT()', description: '分组连接字符串' },
      { name: 'FIND_IN_SET()', description: '在集合中查找' },
      { name: 'MAKE_SET()', description: '创建集合' },
      { name: 'ELT()', description: '返回第N个字符串' },
      { name: 'FIELD()', description: '返回字符串位置' },
      { name: 'INET_ATON()', description: 'IP转数字' },
      { name: 'INET_NTOA()', description: '数字转IP' },
      { name: 'IS_IPV4()', description: '检查IPv4' },
      { name: 'IS_IPV6()', description: '检查IPv6' },
      { name: 'UUID()', description: '生成UUID' },
      { name: 'UUID_SHORT()', description: '生成短UUID' },
      { name: 'BIN_TO_UUID()', description: '二进制转UUID' },
      { name: 'UUID_TO_BIN()', description: 'UUID转二进制' },
      { name: 'RAND()', description: '随机数' },
      { name: 'RANDOM_BYTES()', description: '随机字节' },
      { name: 'ENCRYPT()', description: '加密' },
      { name: 'DECRYPT()', description: '解密' },
      { name: 'AES_ENCRYPT()', description: 'AES加密' },
      { name: 'AES_DECRYPT()', description: 'AES解密' },
      { name: 'MD5()', description: 'MD5哈希' },
      { name: 'SHA1()', description: 'SHA1哈希' },
      { name: 'SHA2()', description: 'SHA2哈希' },
      { name: 'PASSWORD()', description: '密码哈希' },
      { name: 'ENCODE()', description: '编码' },
      { name: 'DECODE()', description: '解码' },
      { name: 'COMPRESS()', description: '压缩' },
      { name: 'UNCOMPRESS()', description: '解压' },
      { name: 'LAST_INSERT_ID()', description: '最后插入ID' },
      { name: 'FOUND_ROWS()', description: '找到的行数' },
      { name: 'ROW_COUNT()', description: '影响的行数' },
      { name: 'SESSION_USER()', description: '会话用户' },
      { name: 'SYSTEM_USER()', description: '系统用户' },
      { name: 'USER()', description: '当前用户' },
      { name: 'CURRENT_USER()', description: '当前用户' },
      { name: 'DATABASE()', description: '当前数据库' },
      { name: 'SCHEMA()', description: '当前模式' },
      { name: 'VERSION()', description: 'MySQL版本' },
      { name: 'CONNECTION_ID()', description: '连接ID' },
      { name: 'CHARSET()', description: '字符集' },
      { name: 'COLLATION()', description: '排序规则' },
      { name: 'LAST_DAY()', description: '月份最后一天' },
      { name: 'MAKEDATE()', description: '创建日期' },
      { name: 'MAKETIME()', description: '创建时间' },
      { name: 'PERIOD_ADD()', description: '添加期间' },
      { name: 'PERIOD_DIFF()', description: '期间差' },
      { name: 'QUARTER()', description: '季度' },
      { name: 'SEC_TO_TIME()', description: '秒转时间' },
      { name: 'TIME_TO_SEC()', description: '时间转秒' },
      { name: 'TO_DAYS()', description: '转天数' },
      { name: 'FROM_DAYS()', description: '天数转日期' },
      { name: 'WEEKDAY()', description: '星期几' },
      { name: 'YEARWEEK()', description: '年周' },
      { name: 'GET_FORMAT()', description: '获取格式' },
      { name: 'STR_TO_DATE()', description: '字符串转日期' },
      { name: 'DATE_FORMAT()', description: '日期格式化' },
      { name: 'TIME_FORMAT()', description: '时间格式化' },
      { name: 'FROM_UNIXTIME()', description: 'UNIX时间戳转日期' },
      { name: 'UNIX_TIMESTAMP()', description: '日期转UNIX时间戳' },
      { name: 'UTC_DATE()', description: 'UTC日期' },
      { name: 'UTC_TIME()', description: 'UTC时间' },
      { name: 'UTC_TIMESTAMP()', description: 'UTC时间戳' },
      { name: 'WEEK()', description: '周数' },
      { name: 'YEAR()', description: '年份' },
      { name: 'QUARTER()', description: '季度' },
      { name: 'MONTH()', description: '月份' },
      { name: 'DAYOFWEEK()', description: '星期几' },
      { name: 'DAYOFMONTH()', description: '月中第几天' },
      { name: 'DAYOFYEAR()', description: '年中第几天' },
      { name: 'MONTHNAME()', description: '月份名称' },
      { name: 'DAYNAME()', description: '星期名称' },
      { name: 'HOUR()', description: '小时' },
      { name: 'MINUTE()', description: '分钟' },
      { name: 'SECOND()', description: '秒' },
      { name: 'MICROSECOND()', description: '微秒' },
      { name: 'EXTRACT()', description: '提取日期部分' },
      { name: 'DATE_ADD()', description: '日期加法' },
      { name: 'DATE_SUB()', description: '日期减法' },
      { name: 'ADDDATE()', description: '添加日期' },
      { name: 'SUBDATE()', description: '减去日期' },
      { name: 'ADDTIME()', description: '添加时间' },
      { name: 'SUBTIME()', description: '减去时间' },
      { name: 'TIMEDIFF()', description: '时间差' },
      { name: 'TIMESTAMPDIFF()', description: '时间戳差' },
      { name: 'TO_SECONDS()', description: '转秒数' },
      { name: 'TIME_TO_SEC()', description: '时间转秒' },
      { name: 'SEC_TO_TIME()', description: '秒转时间' },
      { name: 'MAKETIME()', description: '创建时间' },
      { name: 'TIMESTAMP()', description: '时间戳' },
      { name: 'TIMESTAMPADD()', description: '添加时间戳' },
      { name: 'TIMESTAMPDIFF()', description: '时间戳差' },
      { name: 'TO_DAYS()', description: '转天数' },
      { name: 'FROM_DAYS()', description: '天数转日期' },
      { name: 'LAST_DAY()', description: '月份最后一天' },
      { name: 'MAKEDATE()', description: '创建日期' },
      { name: 'PERIOD_ADD()', description: '添加期间' },
      { name: 'PERIOD_DIFF()', description: '期间差' },
      { name: 'QUARTER()', description: '季度' },
      { name: 'WEEK()', description: '周数' },
      { name: 'WEEKDAY()', description: '星期几' },
      { name: 'WEEKOFYEAR()', description: '年中第几周' },
      { name: 'YEARWEEK()', description: '年周' },
      { name: 'GET_FORMAT()', description: '获取格式' },
      { name: 'STR_TO_DATE()', description: '字符串转日期' },
      { name: 'DATE_FORMAT()', description: '日期格式化' },
      { name: 'TIME_FORMAT()', description: '时间格式化' },
      { name: 'FROM_UNIXTIME()', description: 'UNIX时间戳转日期' },
      { name: 'UNIX_TIMESTAMP()', description: '日期转UNIX时间戳' },
      { name: 'UTC_DATE()', description: 'UTC日期' },
      { name: 'UTC_TIME()', description: 'UTC时间' },
      { name: 'UTC_TIMESTAMP()', description: 'UTC时间戳' }
    ]
  },
  {
    name: 'sqlserver_functions',
    label: 'SQL Server函数',
    keywords: [
      { name: 'JSON_VALUE()', description: '提取JSON值' },
      { name: 'JSON_QUERY()', description: '提取JSON对象' },
      { name: 'JSON_MODIFY()', description: '修改JSON' },
      { name: 'ISJSON()', description: '检查JSON' },
      { name: 'STRING_AGG()', description: '字符串聚合' },
      { name: 'STRING_SPLIT()', description: '字符串分割' },
      { name: 'STRING_ESCAPE()', description: '字符串转义' },
      { name: 'TRANSLATE()', description: '字符转换' },
      { name: 'TRIM()', description: '去除空格' },
      { name: 'CONCAT_WS()', description: '带分隔符连接' },
      { name: 'FORMAT()', description: '格式化' },
      { name: 'IIF()', description: '条件判断' },
      { name: 'CHOOSE()', description: '选择值' },
      { name: 'TRY_CAST()', description: '安全类型转换' },
      { name: 'TRY_CONVERT()', description: '安全转换' },
      { name: 'TRY_PARSE()', description: '安全解析' },
      { name: 'PARSE()', description: '解析' },
      { name: 'EOMONTH()', description: '月份最后一天' },
      { name: 'DATEFROMPARTS()', description: '创建日期' },
      { name: 'DATETIMEFROMPARTS()', description: '创建日期时间' },
      { name: 'SMALLDATETIMEFROMPARTS()', description: '创建小日期时间' },
      { name: 'TIMEFROMPARTS()', description: '创建时间' },
      { name: 'DATETIMEOFFSETFROMPARTS()', description: '创建日期时间偏移' },
      { name: 'DATETIME2FROMPARTS()', description: '创建日期时间2' },
      { name: 'DATEDIFF_BIG()', description: '大日期差' },
      { name: 'AT TIME ZONE', description: '时区转换' },
      { name: 'SWITCHOFFSET()', description: '切换偏移' },
      { name: 'TODATETIMEOFFSET()', description: '转日期时间偏移' },
      { name: 'SYSUTCDATETIME()', description: '系统UTC日期时间' },
      { name: 'SYSDATETIME()', description: '系统日期时间' },
      { name: 'SYSDATETIMEOFFSET()', description: '系统日期时间偏移' },
      { name: 'GETUTCDATE()', description: '获取UTC日期' },
      { name: 'GETDATE()', description: '获取日期' },
      { name: 'CURRENT_TIMESTAMP', description: '当前时间戳' },
      { name: 'GETUTCDATE()', description: '获取UTC日期' },
      { name: 'GETDATE()', description: '获取日期' },
      { name: 'SYSDATETIME()', description: '系统日期时间' },
      { name: 'SYSUTCDATETIME()', description: '系统UTC日期时间' },
      { name: 'SYSDATETIMEOFFSET()', description: '系统日期时间偏移' },
      { name: 'CURRENT_TIMESTAMP', description: '当前时间戳' },
      { name: 'DATENAME()', description: '日期部分名称' },
      { name: 'DATEPART()', description: '日期部分' },
      { name: 'DAY()', description: '日' },
      { name: 'MONTH()', description: '月' },
      { name: 'YEAR()', description: '年' },
      { name: 'ISDATE()', description: '检查日期' },
      { name: 'DATEDIFF()', description: '日期差' },
      { name: 'DATEADD()', description: '添加日期' },
      { name: 'DATEDIFF_BIG()', description: '大日期差' },
      { name: 'EOMONTH()', description: '月份最后一天' },
      { name: 'SWITCHOFFSET()', description: '切换偏移' },
      { name: 'TODATETIMEOFFSET()', description: '转日期时间偏移' },
      { name: 'AT TIME ZONE', description: '时区转换' },
      { name: 'DATEFROMPARTS()', description: '创建日期' },
      { name: 'DATETIMEFROMPARTS()', description: '创建日期时间' },
      { name: 'SMALLDATETIMEFROMPARTS()', description: '创建小日期时间' },
      { name: 'TIMEFROMPARTS()', description: '创建时间' },
      { name: 'DATETIMEOFFSETFROMPARTS()', description: '创建日期时间偏移' },
      { name: 'DATETIME2FROMPARTS()', description: '创建日期时间2' },
      { name: 'NEWID()', description: '生成GUID' },
      { name: 'NEWSEQUENTIALID()', description: '生成顺序GUID' },
      { name: 'HASHBYTES()', description: '哈希' },
      { name: 'CHECKSUM()', description: '校验和' },
      { name: 'BINARY_CHECKSUM()', description: '二进制校验和' },
      { name: 'ENCRYPTBYKEY()', description: '密钥加密' },
      { name: 'DECRYPTBYKEY()', description: '密钥解密' },
      { name: 'ENCRYPTBYPASSPHRASE()', description: '密码加密' },
      { name: 'DECRYPTBYPASSPHRASE()', description: '密码解密' },
      { name: 'SIGNBYASYMKEY()', description: '非对称密钥签名' },
      { name: 'VERIFYSIGNEDBYASYMKEY()', description: '验证非对称密钥签名' },
      { name: 'SIGNBYCERT()', description: '证书签名' },
      { name: 'VERIFYSIGNEDBYCERT()', description: '验证证书签名' },
      { name: 'CERTENCODED()', description: '证书编码' },
      { name: 'CERTPRIVATEKEY()', description: '证书私钥' },
      { name: 'ASYMKEY_ID()', description: '非对称密钥ID' },
      { name: 'CERT_ID()', description: '证书ID' },
      { name: 'SYMKEY_ID()', description: '对称密钥ID' },
      { name: 'KEY_ID()', description: '密钥ID' },
      { name: 'KEY_GUID()', description: '密钥GUID' },
      { name: 'DECRYPTBYKEYAUTOASYMKEY()', description: '自动非对称密钥解密' },
      { name: 'DECRYPTBYKEYAUTOCERT()', description: '自动证书解密' },
      { name: 'SUSER_SNAME()', description: '安全主体名称' },
      { name: 'SUSER_SID()', description: '安全主体ID' },
      { name: 'USER_NAME()', description: '用户名' },
      { name: 'USER_ID()', description: '用户ID' },
      { name: 'SCHEMA_NAME()', description: '模式名' },
      { name: 'SCHEMA_ID()', description: '模式ID' },
      { name: 'OBJECT_NAME()', description: '对象名' },
      { name: 'OBJECT_ID()', description: '对象ID' },
      { name: 'COL_NAME()', description: '列名' },
      { name: 'COL_LENGTH()', description: '列长度' },
      { name: 'COLUMNPROPERTY()', description: '列属性' },
      { name: 'TYPEPROPERTY()', description: '类型属性' },
      { name: 'FULLTEXTSERVICEPROPERTY()', description: '全文服务属性' },
      { name: 'INDEXPROPERTY()', description: '索引属性' },
      { name: 'OBJECTPROPERTY()', description: '对象属性' },
      { name: 'OBJECTPROPERTYEX()', description: '对象属性扩展' },
      { name: 'SQL_VARIANT_PROPERTY()', description: 'SQL变体属性' },
      { name: 'DATABASEPROPERTYEX()', description: '数据库属性扩展' },
      { name: 'SERVERPROPERTY()', description: '服务器属性' },
      { name: 'CONNECTIONPROPERTY()', description: '连接属性' },
      { name: 'SESSIONPROPERTY()', description: '会话属性' },
      { name: 'APP_NAME()', description: '应用名称' },
      { name: 'APPLOCK_MODE()', description: '应用锁模式' },
      { name: 'APPLOCK_TEST()', description: '应用锁测试' },
      { name: 'ASSEMBLYPROPERTY()', description: '程序集属性' },
      { name: 'COLUMNPROPERTY()', description: '列属性' },
      { name: 'DATABASEPROPERTYEX()', description: '数据库属性扩展' },
      { name: 'DB_ID()', description: '数据库ID' },
      { name: 'DB_NAME()', description: '数据库名' },
      { name: 'FILE_ID()', description: '文件ID' },
      { name: 'FILE_NAME()', description: '文件名' },
      { name: 'FILEGROUP_ID()', description: '文件组ID' },
      { name: 'FILEGROUP_NAME()', description: '文件组名' },
      { name: 'FILEGROUPPROPERTY()', description: '文件组属性' },
      { name: 'FILEPROPERTY()', description: '文件属性' },
      { name: 'FULLTEXTCATALOGPROPERTY()', description: '全文目录属性' },
      { name: 'FULLTEXTSERVICEPROPERTY()', description: '全文服务属性' },
      { name: 'INDEXPROPERTY()', description: '索引属性' },
      { name: 'OBJECTPROPERTY()', description: '对象属性' },
      { name: 'OBJECTPROPERTYEX()', description: '对象属性扩展' },
      { name: 'SQL_VARIANT_PROPERTY()', description: 'SQL变体属性' },
      { name: 'SERVERPROPERTY()', description: '服务器属性' },
      { name: 'SESSIONPROPERTY()', description: '会话属性' },
      { name: 'STATS_DATE()', description: '统计日期' },
      { name: 'TYPE_ID()', description: '类型ID' },
      { name: 'TYPE_NAME()', description: '类型名' },
      { name: 'TYPEPROPERTY()', description: '类型属性' }
    ]
  }
]

const filteredKeywords = (keywords) => {
  if (!searchText.value) return keywords
  return keywords.filter(keyword => 
    keyword.name.toLowerCase().includes(searchText.value.toLowerCase()) ||
    keyword.description.toLowerCase().includes(searchText.value.toLowerCase())
  )
}

const useKeyword = (keyword) => {
  emit('use', keyword.name)
}

const emit = defineEmits(['use'])

defineExpose({
  show: () => {
    dialogVisible.value = true
  }
})
</script>

<style scoped>
.sql-keywords {
  .keywords-container {
    height: 500px;
    display: flex;
    flex-direction: column;
  }

  .keywords-header {
    margin-bottom: 20px;
  }

  .keywords-content {
    flex: 1;
    overflow: auto;
  }

  .keywords-grid {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    padding: 10px;
  }

  .el-button {
    white-space: normal;
    word-break: break-all;
    height: auto;
    padding: 8px 12px;
    line-height: 1.4;
    text-align: left;
    display: flex;
    flex-direction: column;
    gap: 8px;
    min-width: 150px;
  }

  .el-button span {
    font-size: 14px;
    color: #666;
  }
}
</style> 